package exam.huawei8_26;

import java.util.Scanner;

public class main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int num [][] = new int[n][m];
        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                num[i][j] = scanner.nextInt();
            }
        }
        int[][] f = new int[n+1][m+1];
        f[0][0] = num[0][0];

        for (int i = 1; i < n ; i++) {
            f[i][0] = f[i-1][0]+num[i][0];
            max = Math.max(max,f[i][0]);
        }

        for (int i = 1; i < m ; i++) {
            f[0][i] = f[0][i-1]+num[0][i];
            max = Math.max(max,f[0][i]);
        }

        for (int i = 1; i < n; i++) {
            for (int j = 1; j < m; j++) {
                f[i][j] = f[i-1][j]+f[i][j-1]-f[i-1][j-1]+num[i][j];
            }
        }
        int sum = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i ;j<n;j++){
                for (int k = 0; k < m; k++) {
                    for (int l = k; l < m ; l++) {
                        if(i==0&&k==0){
                            sum = f[j][l];
                        }else if(i==0&&k!=0){
                            sum = f[j][l]-f[j][k-1];
                        }else if(i!=0&&k==0){
                            sum = f[j][l]-f[i-1][l];
                        }else{
                            sum = f[j][l]-f[i-1][l]-f[j][k-1]+f[i-1][k-1];
                        }
                        max = Math.max(max,sum);
                    }
                }
            }
        }
        System.out.println(max);
    }
}
